﻿using System.Collections.ObjectModel;

namespace TotalApplication.services
{
    public static class ObservableCollectionExtension
    {
        public static void MoveToFirst<T>(this ObservableCollection<T> collection, T item)
        {
            int index = collection.IndexOf(item);
            if (index > 0)
            {
                collection.Move(index, 0);
            }
            //if (collection.Remove(item))
            //{
            //    collection.Insert(0, item);
            //}
        }

        public static void MoveToIndex<T>(this ObservableCollection<T> collection, T item, int newIndex)
        {
            int index = collection.IndexOf(item);

            collection.Move(index, newIndex);
            //if (collection.Remove(item))
            //{
            //    collection.Insert(0, item);
            //}MoveToIndex
        }
    }
}
